{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $op == 'add'}class="active"{/if}><a href="{php echo $this->createWebUrl('nav', array('op' => 'add'))}">添加菜单</a></li>
	<li {if $op == 'list'}class="active"{/if}><a href="{php echo $this->createWebUrl('nav', array('op' => 'list'))}">管理菜单</a></li>
</ul>
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit="return check(this);">
	<input type="hidden" name="parentid" value="{$parentid}" />
	<div class="panel panel-default">
	  <div class="panel-heading">
	    <h3 class="panel-title">详细设置</h3>
	  </div>
	  <div class="panel-body">
	  		<div class="form-group">
			    <label for="displayorder" class="col-sm-2 control-label">排序</label>
			    <div class="col-xs-2">
			      <input type="text" name="displayorder" id='displayorder' class="form-control" value="{$item['displayorder']}" placeholder="排序"/>
			    </div>
			</div>
			<div class="form-group">
			    <label for="title" class="col-sm-2 control-label">菜单名称</label>
			    <div class="col-xs-3">
			      <input type="text" name="title" class="form-control" value="{$item['title']}" id='title' placeholder="请输入菜单名称"/>
			    </div>
			</div>
			<div class="form-group">
			    <label for="school" class="col-sm-2 control-label">菜单链接</label>
			    <div class="col-xs-5">
			     {php echo tpl_form_field_link('url',$item['url'])}
			    </div>
			</div>
			<div class="form-group">
			    <label for="title" class="col-sm-2 control-label">系统图标</label>
			    <div class="col-xs-10">
			      {php echo tpl_form_field_icon(icon,$item['icon'])}
	            <span class="help-block">导航的背景图标，系统提供丰富的图标ICON。</span>
			    </div>
			 </div>
			 <div class="form-group">
			    <label for="title" class="col-sm-2 control-label">背景图片</label>
			    <div class="col-xs-4">
			      {php echo tpl_form_field_image(thumb,$item['thumb'])}
	            <span class="help-block">导航的背景图标，图片优先。</span>
			    </div>
			 </div>
			 <div class="form-group">
			    <label for="title" class="col-sm-2 control-label">背景颜色</label>
			    <div class="col-xs-10">
			      {php echo tpl_form_field_color(bgcolor,$item['bgcolor'])}
	              <span class="help-block">导航的背景颜色。</span>
			    </div>
			 </div>
			 <div class="form-group">
                <label for="" class="col-sm-2 control-label">选择小区</label>
                <div class="col-sm-10">
                    <label class="checkbox-inline">  
                        <input type="checkbox" id="checkAll" name="checkAll" data-group="regionid">全部
                    </label>
                  {loop $regions $region}
                    <label class="checkbox-inline">
                      <input type="checkbox" id="regionid" value="{$region['id']}" name='regionid[]' data-group ="regionid" {if @in_array($region['id'], $regs)}checked='checked' {/if}> {$region['city']}{$region['dist']}{$region['title']}
                    </label>
                  {/loop}
                </div>
            </div>
			<div class="form-group">
			    <label for="" class="col-sm-2 control-label"></label>
			    <div class="col-sm-10">
			      <input name="submit" type="submit" value="提交" class="btn btn-primary span3">
					<input type="hidden" name="token" value="{$_W['token']}" />
			    </div>
			</div>
	  </div>
	</div>
	</form>
</div>
<script type="text/javascript">
        function check(form){
            if (!form['title'].value) {
                alert('请输入菜单名称。');
                return false;
            }
            // if (!form['url'].value) {
            //     alert('请输入菜单链接！');
            //     return false;
            // }
            if (!form['icon'].value) {
                alert('请选择系统图标。');
                return false;
            }
            if (!form['bgcolor'].value) {
                alert('请选择图标颜色。');
                return false;
            }
            return true;
        }
        $(function() {
		     $("#checkAll").click(function() {

		            var checked = $(this).get(0).checked;
		            var group = $(this).data('group');
		            $("#regionid[data-group='" +group + "']").each(function(){
		                $(this).get(0).checked = checked;
		            })

		     });
		});
</script>

{template 'common/footer'}